<?php

namespace app\api\model;

class UserMaterialVerify extends Common
{
    static public function index($types, $user_id, $content, $extra='', $status = 0)
    {
        $current_time = time();

        $verify = self::get(['types' => $types, 'user_id' => $user_id]);

        if ($verify) {
            self::update([
                'id' => $verify['id'],
                'content' => $content,
                'extra' => $extra,
                'status' => $status,
                'create_time' => $current_time,
                'update_time' => $current_time,
            ]);
        } else {
            self::create([
                'types' => $types,
                'user_id' => $user_id,
                'content' => $content,
                'extra' => $extra,
                'status' => $status,
                'create_time' => $current_time,
                'update_time' => $current_time,
            ]);
        }
    }
}
